﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace Twipler.Data.Cache
{
	public abstract class DbConnection : IDisposable
	{
		private SqlConnection _connection = null;
		protected SqlConnection Connection
		{
			get
			{
				if (_connection == null)
					_connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["cache"].ConnectionString);

				return _connection;
			}
		}

		public void Dispose()
		{
			if (_connection == null)
				return;

			_connection.Close();
			_connection.Dispose();
		}
	}
}
